package com.example.drawpicture;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends BaseActivity {

    private Timer timer;
    private TimerTask timerTask;
    private PathView pathView1;
    private PathView pathView2;
    private PathView pathView3;
    private PathView pathView4;
    private PathView pathView5;
    private PathView pathView6;
    private PathView pathView7;
    private PathView pathView8;
    private PathView pathView9;
    private PathView pathView10;
    private PathView pathView11;

    private static int count = 0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

//        pathView1 = findViewById(R.id.pathView1);
//        pathView2 = findViewById(R.id.pathView2);
//        pathView3 = findViewById(R.id.pathView3);
//        pathView4= findViewById(R.id.pathView4);
//        pathView5 = findViewById(R.id.pathView5);
//        pathView6 = findViewById(R.id.pathView6);
//        pathView7 = findViewById(R.id.pathView7);
//        pathView8 = findViewById(R.id.pathView8);
//        pathView9= findViewById(R.id.pathView9);
//        pathView10 = findViewById(R.id.pathView10);

        //模拟实时数据
//        timer = new Timer();
//        timerTask = new TimerTask() {
//            @Override
//            public void run() {
//                if (count / 600 == 0){
//                    pathView1.setNum(0.25f);
//                    pathView1.setData(100);
//                } else if (count / 600 == 1) {
//                    pathView2.setNum(0.2f);
//                    pathView2.setData(100);
//                }
//                else if (count / 600 == 2) {
//                    pathView3.setNum(0.3f);
//                    pathView3.setData(100);
//                }
//                else if (count / 600 == 3) {
//                    pathView4.setNum(0.4f);
//                    pathView4.setData(100);
//                }
//                else if (count / 600 == 4) {
//                    pathView5.setNum(0.5f);
//                    pathView5.setData(100);
//                } else if (count / 600 == 5){
//                    pathView6.setNum(0.6f);
//                    pathView6.setData(100);
//                } else if (count / 600 == 6) {
//                    pathView7.setNum(0.7f);
//                    pathView7.setData(100);
//                }
//                else if (count / 600 == 7) {
//                    pathView8.setNum(0.8f);
//                    pathView8.setData(100);
//                }
//                else if (count / 600 == 8) {
//                    pathView9.setNum(0.9f);
//                    pathView9.setData(100);
//                }
//                else if (count / 600 == 9) {
//                    pathView10.setNum(1);
//                    pathView10.setData(100);
//                }
//                count++;
//            }
//        };
//        timer.schedule(timerTask, 0, 10);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        timerTask.cancel();
        timer.cancel();
        timerTask = null;
        timer = null;
    }

    @Override
    public void next(View view,float absoluteY,float Y) {
        Log.d("next","---next-->>>" + Y);
        Log.d("next","---absoluteY-->>>" + absoluteY);
//        if (Y == -1) {
//            if (Math.abs(absoluteY - 200) < 50) {
//                pathView1.pollData();
//            } else if (Math.abs(absoluteY - 400) < 70) {
//                pathView2.pollData();
//            } else if (Math.abs(absoluteY - 600) < 70) {
//                pathView3.pollData();
//            } else if (Math.abs(absoluteY - 800) < 70) {
//                pathView4.pollData();
//            } else if (Math.abs(absoluteY - 1000) < 70) {
//                pathView5.pollData();
//            } else if (Math.abs(absoluteY - 1200) < 70) {
//                pathView6.pollData();
//            } else if (Math.abs(absoluteY - 1400) < 100) {
//                pathView7.pollData();
//            } else if (Math.abs(absoluteY - 1600) < 70) {
//                pathView8.pollData();
//            } else if (Math.abs(absoluteY - 1800) < 70) {
//                pathView9.pollData();
//            } else if (Math.abs(absoluteY - 2000) < 70) {
//                pathView10.pollData();
//            }
//        } else {
//            if (Y < 0) {
//                // 向下划
//            } else if (Y > 0) {
//                // 向上划
//            }
//        }
    }

    @Override
    public void pre(View view,float absoluteY,float Y) {
        Log.d("next","---pre-->>>" + Y);
        Log.d("next","---absoluteY-->>>" + absoluteY);
//        if (Math.abs(Y - 200) < 50) {
//            pathView1.pullData();
//        } else if (Math.abs(Y - 400) < 50) {
//            pathView2.pullData();
//        } else if (Math.abs(Y - 600) < 50) {
//            pathView3.pullData();
//        } else if (Math.abs(Y - 800) < 50) {
//            pathView4.pullData();
//        } else if (Math.abs(Y - 1000) < 50) {
//            pathView5.pullData();
//        } else if (Math.abs(Y - 1200) < 50) {
//            pathView6.pullData();
//        } else if (Math.abs(Y - 1400) < 50) {
//            pathView7.pullData();
//        } else if (Math.abs(Y - 1600) < 50) {
//            pathView8.pullData();
//        } else if (Math.abs(Y - 1800) < 50) {
//            pathView9.pullData();
//        } else if (Math.abs(Y - 2000) < 50) {
//            pathView10.pullData();
//        }
    }

}
